import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

/// 币种选择界面IconWidget
class GTCoinIcon extends StatelessWidget {
  const GTCoinIcon({Key? key, required this.url, this.size = 24})
      : super(key: key);
  final String url;
  final double size;

  @override
  Widget build(BuildContext context) {
    return url.isNotEmpty
        ? CachedNetworkImage(
            imageUrl: url,
            width: size,
            height: size,
            placeholder: (context, url) => _defaultCoin(),
            errorWidget: (context, url, error) => _defaultCoin(),
          )
        : _defaultCoin();
  }
  _defaultCoin(){
    return Image.asset(
      "assets/images/ic_lend_default_coin_icon.webp",
      package: "lib_uikit",
      width: size,
      height: size,
    );
  }
}
